<?php
/**
 * Created by IntelliJ IDEA.
 * User: lee
 * Date: 2018/10/26
 * Time: 2:12 PM
 */

namespace Biz\module\Classes;

use Biz\model\trade\Order as mOrder;
use Doraemon\service\MemberRoleTag as sMemberRoleTag;

class User
{
    // 是否符合新人的条件
    //return
    //      true是新人
    //      false不是新人
    public static function isNewUser($uid)
    {
        static $isNewUser;

        if(is_null($isNewUser)){

            $cTag = sMemberRoleTag::getRoleTagValueByUid($uid,sMemberRoleTag::ROLE_TAG_BUY);

            if(!empty($cTag)){
                if($cTag == 2){
                    $isNewUser = false;

                    return $isNewUser;
                }
            }

            //有已支付的订单，那么也不是新人
            $paiedOrder = mOrder::get(['order_no'], ['uid' => $uid,'pay_no[!]' => '']);

            if(!empty($paiedOrder)){
                $isNewUser = false;

                return $isNewUser;
            }

            //有待付款订单，那么则不是新人
            $waitPaiedOrder = mOrder::get(['order_no'], ['uid' => $uid,'status' => mOrder::STATUS_NORMAL]);
            if(!empty($waitPaiedOrder)){
                $isNewUser = false;

                return $isNewUser;
            }

            $isNewUser=true;

        }

        return $isNewUser;

    }
}